class Queue(object):
    def __init__(self):
        self.items = []

    def enqueue(self, item):
        self.items.insert(0, item)  # 代替 self.items.append(item)

    def dequeue(self):
        return self.items.pop()  # 代替 return self.items.pop(0)

    def isEmpty(self):
        return self.items == []

    def size(self):
        return len(self.items)

n,m=map(int,input().split(' '))
q=Queue()
index=1;
for _ in range(m):
    num=int(input())
    if num==0:
        q.enqueue(index)
        index+=1
    elif num==1:
        q.enqueue(q.dequeue())

for item in q.items:
    print(item)